import java.util.*;
import java.util.stream.*;

class Solution {
    public String minNumber(final int[] nums) {
        String res = Arrays.stream(nums)
                .boxed()
                .sorted((o1, o2) -> (o1 + "" + o2).compareTo(o2 + "" + o1))
                .map(String::valueOf)
                .collect(Collectors.joining(""));
        return res;
    }

    public static void main(final String[] args) {
        final Solution s = new Solution();
        final int[] arr = {3, 30, 34, 5, 9};
        System.out.println(s.minNumber(arr));
    }
}